package br.com.locanet.view.impl;

import javax.faces.bean.ManagedBean;

import br.com.locanet.bean.impl.Funcionario;
import br.com.locanet.service.impl.FuncionarioService;
import br.com.locanet.view.AbstractManagedBean;

@ManagedBean(name="funcionarioBean")
public class FuncionariosBean extends AbstractManagedBean<Funcionario,FuncionarioService> {
	
	private String conf_senha;
	
	public String insert() throws Exception {
		getEntity().setStatus(1);
		getEntityService().doValidateSenha(getEntity(), getConf_senha());
		return super.insert();
	}
	
	@Override
	public String remove() throws Exception {
		doExclusaoLogica(getEntity());
		return search();
	}
	
	private void doExclusaoLogica(Funcionario func) throws Exception{
		func = getEntityService().selectById(func);
		func.setStatus(func.getStatus()==1?0:1);
		getEntityService().update(func);
	}

	public String getConf_senha() {
		return conf_senha;
	}

	public void setConf_senha(String confSenha) {
		conf_senha = confSenha;
	}

}
